<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>test</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    #canvas {
      display: block;
      border: 1px solid #000;
      margin: 10px auto 0;
    }
  </style>
</head>

<body>
  <canvas id="canvas" width="800" height="600"></canvas>


  <script>
    function draw() {
      var canvas = document.getElementById("canvas");
      if (canvas.getContext) {
        var ctx = canvas.getContext("2d");

        ctx.font = "40px serif";
        ctx.fillText("Hello world", 10, 50);

        ctx.font = "48px serif";
        ctx.strokeText("Hello world", 10, 100);
      }
    }

    draw();
  </script>
</body>

</html>